import request from "@/utils/request";

/**
 * 库存列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function stockList(params = {}){
  return request({
    url: '/stock/stockList',
    method: 'get',
    params
  })
}

/**
 * 库存商品关联适用
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function suitStockGoods(data){
  return request({
    url: '/stock/suitStockGoods',
    method: 'post',
    data
  })
}

/**
 * 提交入库单
 * @param data
 * @returns {Promise<unknown>}
 */
export function addStock(data){
  return request({
    url: '/stock/addStock',
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 获取入库单列表
 * @param params
 * @returns {Promise<unknown>}
 */
export function getStockOrderList(params = {}){
  return request({
    url: '/stock/getStockOrderList',
    method: 'get',
    params
  })
}

/**
 * 获取入库单详情
 * @param stockOrderNo
 * @returns {Promise<unknown>}
 */
export function getStockOrder(stockOrderNo){
  return request({
    url: `/stock/getStockOrder/${stockOrderNo}`,
    method: 'get',
  })
}

/**
 * 获取库存的说明
 * @returns {Promise | Promise<unknown>}
 */
export function getStockHelp(){
  return request({
    url: '/stock/getStockHelp',
  })
}

/**
 * 删除库存
 * @param stockId
 * @returns {Promise<unknown>}
 */
export function deleteStock(stockId){
  return request({
    url: `/stock/${stockId}`,
    method: 'delete',
  })
}

/**
 * 修改库存快递单
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveStockOrderExpress(data){
  return request({
    url: `/stock/saveStockOrderExpress`,
    data,
    method: 'post',
    handleError: true,
  })
}

export function getStockGoodsList(params = {}){
  return request({
    url: '/stock/getStockGoodsList',
    params,
  })
}
